package com.niiwoo.civet.mobile.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.niiwoo.civet.account.dto.request.PayChannelRequestDTO;
import com.niiwoo.civet.account.dto.response.PayChannelResponseDTO;
import com.niiwoo.civet.account.enums.OrderEnum;
import com.niiwoo.civet.account.enums.PayChannelTypeEnum;
import com.niiwoo.civet.account.service.PayChannelDubboService;
import com.niiwoo.civet.mobile.vo.request.PayChannelRequestVO;
import com.niiwoo.civet.mobile.vo.response.PayChannelResponseVO;
import com.niiwoo.tripod.provider.dto.response.PageResponseDTO;
import com.niiwoo.tripod.provider.exception.BizException;
import com.niiwoo.tripod.web.annotation.AuthIgnore;
import com.niiwoo.tripod.web.vo.Empty;
import com.niiwoo.tripod.web.vo.PageResponseVO;
import com.niiwoo.tripod.web.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/payChannel")
@Api(tags = "支付渠道维护-肖耀才", description = "/payChannel")
public class PayChannelController {

    @Reference(version = "1.0.0")
    private PayChannelDubboService payChannelDubboService;

    @AuthIgnore
    @PostMapping("/getPayChannelPayment")
    @ApiOperation("支付渠道列表")
    public Result<List<PayChannelResponseVO>> getPayChannelPayment(){
        List<PayChannelResponseVO> payChannelResponseVOS = new ArrayList<PayChannelResponseVO>();
        PayChannelRequestDTO requestDTO = new PayChannelRequestDTO();
        requestDTO.setPayChannelTypeEnum(PayChannelTypeEnum.PAYMENT);
        requestDTO.setOrderEnum(OrderEnum.DESC);
        requestDTO.setStatus((byte)1);
        List<PayChannelResponseDTO> payChannelResponseDTOS = payChannelDubboService.getRechargePayChannel(requestDTO);
        if( null != payChannelResponseDTOS){
            for(PayChannelResponseDTO payChannelResponseDTO:payChannelResponseDTOS){
                PayChannelResponseVO vo = new PayChannelResponseVO();
                vo.setId(payChannelResponseDTO.getId());
                vo.setChannelCode(payChannelResponseDTO.getChannelCode());
                vo.setChannelName(payChannelResponseDTO.getChannelName());
                vo.setChannelType(payChannelResponseDTO.getChannelType());
                payChannelResponseVOS.add(vo);
            }
        }
        return Result.with(payChannelResponseVOS);
    }

}
